//#include <stdio.h>
////复习题4
//int main(int size,char ** args){
//    if (size<2){
//        puts("请输入浮点数");
//        double val;
//        double sum = 0;
//        while (scanf("%lf",&val)==1){
//            sum += val;
//        }
//        printf("sum = %.3f", sum);
//    } else if (size == 2) {
//        FILE *file = fopen(args[1], "r");
//        double val;
//        double sum = 0;
//        while (fscanf(file,"%lf",&val)==1){
//            sum += val;
//        }
//        printf("sum = %.3f", sum);
//    } else{
//        fprintf(stderr, "参数过多\n");
//    }
//    return 0;
//}


// 复习题5
#include <stdio.h>
#include <string.h>
#define MAX_LINE_LENGTH 256
int main(int size,char ** args){
    if (size < 3) {
        puts("Usage p5 string filename");
    } else{
        char *st = args[1];
        char line[MAX_LINE_LENGTH];
        FILE *file;
        if ((file = fopen(args[2], "r")) != NULL) {
            printf("rest is contain \"%s\":\n", st);
            while (fgets(line, MAX_LINE_LENGTH, file) != NULL) {
                if (strstr(line, st)) {
                    printf(line);
                }
            }
        } else{
            printf("Not found the file of name %s", args[2]);
        }
    }
}